import request from "@/utils/request";


/**
 * 获取贴标单详情
 * @param id
 * @returns {Promise | Promise<unknown>}
 */
export function getLabelOrderInfo(id, params = {}){
  return request({
    url: `/labelOrder/getLabelOrderInfo/${id}`,
    method: 'get',
    handleError: true,
    params
  })
}


/**
 * 导出SKU标
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function exportLabelGoodsLabelPdf(params){
  return request({
    url: `/labelOrder/exportLabelGoodsLabelPdf`,
    method: 'get',
    responseType: "arraybuffer",
    isNotJson: true,
    timeout: 60000 * 5, // 1分钟
    handleError: true,
    params,
  })
}

/**
 * 保存数量
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function saveRlGoodsNum(data){
  return request({
    url: `/labelOrder/saveRlGoodsNum`,
    method: 'patch',
    handleError: true,
    data,
  })
}

/**
 * 保存多条数据
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function saveBatchRlGoodsNum(data){
  return request({
    url: `/labelOrder/saveBatchRlGoodsNum`,
    method: 'patch',
    handleError: true,
    data,
  })
}

/**
 * 确认贴标
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function finishLabelOrder(data){
  return request({
    url: `/labelOrder/finishLabelOrder`,
    method: 'post',
    data,
    handleError: true,
  })
}

/**
 * 获取贴标列表
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getLabelOrderList(params = {}){
  return request({
    url: `/labelOrder/getLabelOrderList`,
    method: 'get',
    params,
  })
}

/**
 * 导出拣货单
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function exportLabelThermalPdf(data){
  return request({
    url: `/labelOrder/exportLabelThermalPdf`,
    method: 'post',
    data,
    responseType: "arraybuffer",
    isNotJson: true,
    timeout: 60000 * 5, // 1分钟
    handleError: true,
  })
}

/**
 * 部分贴标
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function labelPartGoods(data){
  return request({
    url: '/labelOrder/labelPartGoods',
    method: 'put',
    data,
    handleError: true,
  })
}
